#include <string>
#include <iostream>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <stack>
#include <algorithm>
using namespace std;
int main() {
string *c = new string[100];
int i=0;
int h, o;
string g, n = "";
 while (cin >> g)
  {
    c[i++] = g;
  }

for(int j=0;j<i;j++)
{
if(c[j]=="zero")
    n+="0";
else if (c[j]=="one")
    n+="1";
else if (c[j]=="two")
    n+="2";
else if (c[j]=="three")
    n+="3";
else if (c[j]=="four")
    n+="4";
else if (c[j]=="five")
    n+="5";
else if (c[j]=="six")
    n+="6";
else if (c[j]=="seven")
    n+="7";
else if (c[j]=="eight")
    n+="8";
else if (c[j]=="nine")
    n+="9";
else{
    cout<<"Wrong input";
    return 0;}
}
if(n.size() < 3 || n.size() > 3){
    cout<<"Wrong input";
    return 0;
}
h = stoi(n);
int* a = new int[1000];
  for (int i = 0; i < 1000; i++)
    a[i] = i;
  for (int p = 2; p < 1000; p++)
  {
    if (a[p] != 0)
    {
      if(abs(a[p] - stoi(n)) < h){
            h = abs(a[p] - stoi(n));
            o = p;
      }
      for (int j = p * p; j < 1000; j += p)
        a[j] = 0;
    }
  }
  cout << a[o];
}
